	
	****************************************************************************
	******************************** HSLS 2009 *********************************
	****************************************************************************
	
	**** Round 2
	
	clear all
	set more off
	set maxvar 15000
	
	use "C:\Users\EAsker\Desktop\ABR\hsls_09\RFHLS09_data\hsls09.dta" , clear
	
	rename *, lower
	
	*Keeping only public schools
	keep if  x1control==1
	
	gen survey=2009
	label var survey "HSLS 2009"
	gen wave=2
	label var wave "Survey time: (2 Years After HS)"

	rename x1state fips_state
	rename x1ncesid ncesid
	rename x1race race_by
	rename x1sex sex_by
	rename x1famincome fam_inc
	
	rename w4student weight
	rename (x1dadedu x1momedu) (fat_edu mot_edu) 
	
	ren x1region region
	label var region "schools' region"
	
	replace ncesid=substr(ncesid,1,7)
	destring ncesid, replace
	destring stu_id, replace
	destring sch_id, replace
	
	recode mot_edu (0=.)  (-9/-8=.)
	gen mot_hs=mot_edu>=2 if mot_edu~=.

	recode fat_edu (0=.)  (-9/-8=.)
	gen fat_hs=fat_edu>=2 if fat_edu~=.

	label var fat_hs "Dummy: 1 if respondent's father graduted from a HS"
	label var mot_hs "Dummy: 1 if respondent's mother graduted from a HS"
	
	recode fam_inc (1=15000) (2=35000) (3=55000) (4=75000) (5=95000) ///
	(6=115000) (7=135000) (8=155000) (9=175000) (10=195000) (11=215000) ///
	(12=235000) (13=300000) (-9/-8=.)
	
	replace fam_inc=fam_inc*(237/215.3) //multiplying with the deflator
	
	label var fam_inc "Family income adjusted for inflation"
	
	recode race_by (-9=.)
	gen white=race_by==8 if race_by~=.
	gen black=race_by==3 if race_by~=.
	gen hispanic=race_by==4|race_by==5 if race_by~=.
	gen oth_race=race_by==1|race_by==2|race_by==6|race_by==7 if race_by~=.
	
	recode sex_by (-9=.)
	gen female=sex_by==2 if sex_by~=.
	
		gen not_white=.
		replace not_white=1 if black==1|hispanic==1|oth_race==1
		replace not_white=0 if white==1
	
	label var white "Dummy: 1 if respondent is a white"
	label var black "Dummy: 1 if respondent is black"
	label var hispanic "Dummy: 1 if respondent is hispanic"
	label var oth_race "Dummy: 1 if respondent is other race"
	label var female "Dummy: 1 if respondent is female"
	
*************************************************************
	
	*	High School Graduation
	recode  x3hscompstat  (-6=.) (5=.)
	gen high_school= x3hscompstat==1 if  x3hscompstat~=.
	label var high_school "Dummy: 1 if repondent has a HS diploma"
	
	*	Voluntary hours
	recode s4hrsvoluntr (-8=.) (-4=.) (-9=.) (-6=.)
	gen vlntry_hours=s4hrsvoluntr/4
	sum vlntry_hours, detail
	replace vlntry_hours=r(p99) if  vlntry_hours>r(p99)&vlntry_hours~=.
	label var vlntry_hours "Number of voluntary hours in a month"
	
	*	Voluntary Particapation
	gen vltnry_prtcptn=1 if vlntry_hours>0&vlntry_hours~=.
	replace vltnry_prtcptn=0 if vlntry_hours==0&vlntry_hours~=.
	label var vltnry_prtcptn ///
	"Dummy:1 if respondent ever involved in voluntary activities"

	*	Register Vote
	recode s4regvote (-8=.) (-4=.) (-9=.) (-6=.) (3=.)
	
	gen register_vote=s4regvote==1 if s4regvote~=.
	label var register_vote "Dummy:1 if respondent ever registired to vote"
	
	*	Postsecondary Education
	recode   s4evratndclg (-9/-3=.)
	
	gen post_scndry= s4evratndclg==1 if  s4evratndclg~=.
	label var post_scndry "Dummy: 1 ever attanded PSE institution"

	keep  fips_state ncesid survey wave stu_id sch_id mot_hs fat_hs white ///
	black hispanic oth_race female high_school vltnry_prtcptn post_scndry ///
	register_vote fam_inc vlntry_hours not_white weight 
	
	save "C:\Users\EAsker\Desktop\ABR\hsls_09\RFHLS09_Clean_data\RFHLS09.dta" ,replace

	
	
	
	
	
	
	